#ifndef ACCOUNT_HH
#define ACCOUNT_HH

#include <string>
#include <vector>
#include "Transaction.hh"

namespace mini_bank {

class Account {
protected:
    std::string accountId;
    std::string ownerName;
    double balance;
    std::vector<Transaction> transactions;

public:
    virtual bool canDeposit() const = 0; 
    virtual bool canWithdraw() const = 0;
    Account(const std::string& id,
            const std::string& owner,
            double initialBalance);
    virtual ~Account() = default;

    std::string getId() const;
    std::string getOwnerName() const;
    double getBalance() const;

    virtual bool deposit(double amount, const std::string& note, bool isTransfer = false) = 0;
    virtual bool withdraw(double amount, const std::string& note) = 0;
    virtual bool transfer(Account& target,
                          double amount,
                          const std::string& note,
                          bool isTransfer = false) = 0;

    void addTransaction(const Transaction& tx);
    const std::vector<Transaction>& getTransactions() const;
};

class SavingsAccount : public Account {
public:
    bool canDeposit() const override { return false; }
    bool canWithdraw() const override { return false; }
    using Account::Account;
    bool deposit(double amount, const std::string& note, bool isTransfer = false) override;
    bool withdraw(double amount, const std::string& note) override;
    bool transfer(Account& target,
                  double amount,
                  const std::string& note,
                  bool isTransfer = false) override;
};

class CheckingAccount : public Account {
public:
    bool canDeposit() const override { return true; }
    bool canWithdraw() const override { return true; }
    using Account::Account;
    bool deposit(double amount, const std::string& note, bool isTransfer = false) override;
    bool withdraw(double amount, const std::string& note) override;
    bool transfer(Account& target,
                  double amount,
                  const std::string& note,
                  bool isTransfer = false) override;
};
}

#endif // ACCOUNT_HH
